package xmlS
{
	import main.XMLLoaderBase;
	
	public class RecommendPathXmlLoader extends XMLLoaderBase
	{
		private var xmlData:XML;
		
		private var delayFuction:Function;
		private var objectList:Array = [];
		
		public function RecommendPathXmlLoader()
		{
		}
		
		public function initThis(func:Function = null):void
		{
			delayFuction = func;
			loadXml(uri.getScenicXml("RecommendPath"),saveData,loadingThis);
		}
		
		private function saveData(data:XML = null):void
		{
			if(data){
				xmlData = data;
				changeAndSave();
			}
			
			if(delayFuction is Function){
				delayFuction();
				delayFuction = null;
			}
		}
		
		private function changeAndSave():void
		{
			objectList = [];
			
			var list:Array = changeListToArray(xmlData.path);
			for(var i:int = 0;i < list.length;i++){
				var obj:RecommendPathDesign = new RecommendPathDesign;
				obj.init(list[i]);
				
				objectList.push(obj);
			}
		}
		
		private function changeListToArray(list:XMLList):Array
		{
			var valueList:Array = [];
			
			for each(var xml:XML in list){
				valueList.push(xml);
			}
			
			return valueList;
		}
		
		private function loadingThis():void
		{
			trace("正在拉取景区配置");
		}
		
		public function load(keyName:*,keynum:* = null):*
		{
			var value:*;
			
			if(objectList.length == 0){
				initThis(function():void{value = load(keyName,keynum)});
			}else{
				value = getValue(keyName,keynum);
			}
			
			return value;
		}
		
		private function getValue(keyName:*,keyNum:* = null):*
		{
			var info:Object;
			
			if(keyNum != null){
				for(var i:int = 0;i < objectList.length;i++){
					if(objectList[i][keyName] && objectList[i][keyName] == keyNum){
						info = objectList[i]
						return info;
					}
				}
				return null;
			}else{
				return objectList;
			}
		}
	}
}
import main.ClientConstants;

class RecommendPathDesign
{
	public var id:int;
	public var type:int;
	public var name:String;
	public var desc:String;
	public var info:Array;
	public var totalDays:Number;
	public var url:String;
	
	public function RecommendPathDesign()
	{
	}
	
	public function init(xml:XML):void
	{
		this.id = xml.id;
		this.type = xml.type;
		this.name = xml.name;
		this.info = String(xml.info).split("|");
		this.desc = xml.desc;
		this.totalDays = xml.totalDays;
		this.url = xml.url;
	}
}
